var appConsole = require("../../common/AppLog.js").appConsole;

/*按揭税务算法对象*/
var tax=(function(wx){

  /*税务帮助类*/
  var taxTools={

     /*千位符*/
     toThousands:function (num) {
        var num = (num || 0).toString(), result = '';
        while (num.length > 3) {
          result = ',' + num.slice(-3) + result;
          num = num.slice(0, num.length - 3);
        }
        if (num) { result = num + result; }
        appConsole.log("千位符转换为：" + result, 2);
        return result;
      },
      
      /*转换为布尔值*/
      toBoolean:function(boolStr){
        if(boolStr==="true"){
          return true;
        }
        if(boolStr==="false"){
          return false;
        }
      },

      /*澳门币转港币*/
      maToHK: function (fee) {
        appConsole.log("澳门币转换为："+fee,2);
      },
     
      /*百分比转换 */
      toPercentage:function(fee){
        appConsole.log("百分比转换" + (fee/100), 2);
        return fee/100;
      }

  }



  /*税务验证对象*/
  var verifyContext={
      

  }
 
  /*显隐对象*/
  var displayContext={
     "tax-type-buy":function(displayObj,currentData){
       displayObj.txt_register_display=true;
       displayObj.tax_first_display = true;
       displayObj.tax_extraTax_display=true;

       displayObj.tax_gtax_display=false;
       displayObj.tax_isGtax=true;

       if (currentData.agParam.tax_first == true) {
         displayObj.tax_extraTax_display = false;
         displayObj.tax_gtax_display = false;
         displayObj.tax_isGtax = false;
       }

    }, 
     "tax-type-buyAndMortgage": function (displayObj, currentData){
       displayObj.txt_register_display = true;
       displayObj.txt_loan_display=true;
       displayObj.tax_rate_display=true;
       displayObj.tax_first_display = true;
       displayObj.tax_extraTax_display = true;  

    
       displayObj.tax_isGtax=true;   

       if (currentData.agParam.tax_isGtax == "true") {
         displayObj.tax_gtax_display = true;
       }
       if (currentData.agParam.tax_first == true) {
         displayObj.tax_extraTax_display = false;
         displayObj.tax_gtax_display = false;
         displayObj.tax_isGtax = false;
       }

     },
     "tax-type-mortgage": function (displayObj){
       displayObj.txt_loan_display=true;
       displayObj.tax_rate_display=true;
     },
     "tax-type-register": function (displayObj){
       displayObj.txt_floor_display=true;
     }
  };


  /*计算区间算法对象*/
  var agTaxRangeContext = {
    getFeeByMin: function (registerVal, min) {
      appConsole.log("testM:"+registerVal+":"+min);
      if (registerVal - min >= 0) {
        return min;
      } else {
        return registerVal;
      }
    },
    getFeeByMax: function (registerVal, max) {
      if (registerVal - max > 0) {
        return registerVal - max;
      }
      return 0;
    },
    getFeeByRange: function (registerVal, range) {
      var rangeStart = range[0];
      var rangeEnd = range[1];
      var range = rangeEnd - rangeStart;
     
      if (registerVal - rangeEnd >= 0) {
        return range;
      } else {
        if (registerVal - rangeStart >= 0) {
          //return registerVal - range
          return registerVal - rangeStart
        }
      }
      return 0;
    }
  };


  /*算法入口对象*/
  var agContext={
      /*计算买卖*/
    "tax-type-buy": function (agParam, isMerge){

       /*公证费公式为：
      
       【公证费公式为=总公证手续费+印花税+印花税2+另收款项;】
        
        计算条件：

        售价或财政局登记价值需要转成对应的[港币]或[澳门币]
        
        非首次置业与首次置业的公证手续费会有部分不一样。

        若得出结果有小数点，则进1。

        */


        var nFee=0;
        /*非首次置业公证费*/
        var n_fees_1, n_fees_2, n_fees_3, n_fees_4, n_fees_5;

        /*首次置业公证费*/
        var f_fees_1,f_fees_2,f_fees_3,f_fees_4,f_fees_5,f_fees_6;


        var txt_register=  new Number(agParam.txt_register);

      
        
        appConsole.log("txt_register:" + txt_register);
        var tax_first =agParam.tax_first;
        var tax_extraTax = agParam.tax_extraTax;
        var tax_rateType = agParam.tax_register_currency;
        var tax_gtax=agParam.tax_gtax;
        var tax_isGtax = agParam.tax_isGtax;
     
        /*总手续费交易额*/
        var sumFee;
        /*印花税*/
        var stampTax=0;
        /*印花税2 */
        var stampTax2 = 0;
        /*另收款项*/
        var otherFee=100;
        /*不动产印花税*/
        var realEstateStampTax=0;

        var r_fee_1=0;
        var r_fee_2=0;
        var r_fee_3=0;

        /*登记费*/
        var registerFee=0;
        var rs_fee_1=0;
        var rs_fee_2=0;
        var rs_fee_3=0;

        var sumFee=0;

        /*售价或财政局登记价值转换汇率*/
        if (tax_rateType=="HK"){

           txt_register = txt_register*1.03;

        }


        /* "首次"置业超出区间 */
        if (tax_first){

          f_fees_1 = agTaxRangeContext.getFeeByMin(txt_register, 500000);

          f_fees_2 = agTaxRangeContext.getFeeByRange(txt_register, [500000, 1000000]);

          f_fees_3 = agTaxRangeContext.getFeeByRange(txt_register, [1000000, 2000000]);

          f_fees_4 = agTaxRangeContext.getFeeByRange(txt_register, [2000000, 3000000]);

          f_fees_5 = agTaxRangeContext.getFeeByRange(txt_register, [3000000, 5000000]);

          f_fees_6 = agTaxRangeContext.getFeeByMax(txt_register, 5000000)

          /*逐项计算"首次"公证手续费*/
          f_fees_1 = f_fees_1 * 0.0025;
          f_fees_2 = f_fees_2 * 0.0015;
          f_fees_3 = f_fees_3 * 0.0005;
          f_fees_4 = f_fees_4 * -0.0005;
          f_fees_5 = f_fees_5 * 0.002;
          f_fees_6 = f_fees_6 * 0.001;

          /*计算"首次"置业总公证费*/
          sumFee = f_fees_1 + f_fees_2 + f_fees_3 + f_fees_4 + f_fees_5 + f_fees_6;
        }

        /* 逐项获取"非首次"置业超出区间 */
        else{
          n_fees_1 = agTaxRangeContext.getFeeByMin(txt_register, 500000);

          n_fees_2 = agTaxRangeContext.getFeeByRange(txt_register, [500000, 1000000]);

          n_fees_3 = agTaxRangeContext.getFeeByRange(txt_register, [1000000, 2000000]);
          appConsole.log("n_fees_3:"+n_fees_3);
          n_fees_4 = agTaxRangeContext.getFeeByRange(txt_register, [2000000, 5000000]);
          appConsole.log("n_fees_4:" + n_fees_4);
          n_fees_5 = agTaxRangeContext.getFeeByMax(txt_register, 5000000)

          /*逐项计算"非首次"公证手续费*/
          n_fees_1 = n_fees_1*  0.005;
          n_fees_2 = n_fees_2 * 0.004;
          n_fees_3 = n_fees_3*0.003;
          n_fees_4 = n_fees_4*0.002;
          n_fees_5 = n_fees_5*0.001;
        
          /*计算"非首次"总公证手续费 */
          sumFee =  n_fees_1 + n_fees_2 + n_fees_3 + n_fees_4 + n_fees_5;

          
        }

        /*计算印花税1*/
        stampTax = 20;
        if (txt_register > 30000) {
          stampTax = 100;
        }

        /*计算印花税2 */
        stampTax2 = txt_register * 0.005;

        /*计算总公证费*/
        if (isMerge){
          nFee = (sumFee + stampTax + stampTax2 + otherFee) ;
        }
        else{
          nFee = Math.ceil(sumFee + stampTax + stampTax2 + otherFee);
        }
        

        /*不动产印花税区间 */
        if (tax_first){
         // r_fee_1 = agTaxRangeContext.getFeeByMin(txt_register, 2000000);
          //r_fee_2 = agTaxRangeContext.getFeeByRange(txt_register, [2000000, 4000000]);
          //r_fee_2 = agTaxRangeContext.getFeeByMin(txt_register, 1000000);

          r_fee_2 = agTaxRangeContext.getFeeByRange(txt_register, [3000000, 4000000]);
          console.error("===========r2=============",r_fee_2,tax_first);
          r_fee_3 = agTaxRangeContext.getFeeByMax(txt_register, 4000000);

        
                   
        }else{

          appConsole.log("计算之前：" + txt_register,2);
          r_fee_1 = agTaxRangeContext.getFeeByMin(txt_register, 2000000);

          r_fee_2 = agTaxRangeContext.getFeeByRange(txt_register, [2000000, 4000000]);

          r_fee_3 = agTaxRangeContext.getFeeByMax(txt_register, 4000000);      
        }
        /*
        else{
          r_fee_1 = agTaxRangeContext.getFeeByMin(txt_register, 2000000);

          r_fee_2 = agTaxRangeContext.getFeeByRange(txt_register, [2000000, 4000000]);

          r_fee_3 = agTaxRangeContext.getFeeByMax(txt_register, 4000000);
        }
        */
        //txt_register=67323890;
        //653630000

        appConsole.log(r_fee_1, 1);
        appConsole.log(r_fee_2, 1);
        appConsole.log(r_fee_3, 1);

        /*计算总不动产印花税+额外印花税 */
        //if (tax_first==false){
          if (tax_extraTax) {
            realEstateStampTax = Math.ceil((txt_register * 0.1) +
              (r_fee_1 * 0.01 + r_fee_2 * 0.02 + r_fee_3 * 0.03)) * 1.05;
            realEstateStampTax = Math.ceil(realEstateStampTax);
          } else {
            /*计算总不动产印花税 */
            realEstateStampTax = Math.ceil((r_fee_1 * 0.01) + (r_fee_2 * 0.02) + (r_fee_3 * 0.03)) * 1.05;
            realEstateStampTax = Math.ceil(realEstateStampTax);
          }
        //}

        appConsole.log("不动产印花税1：" + ((r_fee_1*0.01)*1.05));
        appConsole.log("不动产印花税：" + Math.ceil(realEstateStampTax));


        /*不动产印花税转换汇率 */

        

        
        /*逐项获取登记费超出区间 */
    
        rs_fee_1 = agTaxRangeContext.getFeeByMin(txt_register,500000);

        rs_fee_2 = agTaxRangeContext.getFeeByRange(txt_register, [500000, 1000000]);

        rs_fee_3 = agTaxRangeContext.getFeeByMax(txt_register, 1000000);
        if(isMerge){
          registerFee = rs_fee_1 * 0.004 + rs_fee_2 * 0.003 + rs_fee_3 * 0.002 + 100;
        }
        else{
          registerFee = Math.ceil(rs_fee_1 * 0.004 + rs_fee_2 * 0.003 + rs_fee_3 * 0.002 + 100);
        }
        

        /*
        if (tax_rateType == "HK") {
          realEstateStampTax = Math.ceil(realEstateStampTax * 1.03);
        }
        */

        var tg_fee=0;
        /*计算取得额外印花税*/
        /*两套*/
        appConsole.log("agTaxRangeContext.tax_gtax:" + agTaxRangeContext.tax_gtax,2);
        if (tax_isGtax == "true" && tax_first==false){
          if (tax_gtax == "gtax_2") {
            tg_fee = Math.ceil(txt_register * 0.05);

          } else if (tax_gtax == "gtax_3") {
            /*三套以上*/
            tg_fee = Math.ceil(txt_register * 0.1);
          }
        }


        appConsole.log("agParam.tax_gtax:" + tax_gtax, 1);
        appConsole.log("agParam.tg_fee:" + tg_fee, 1);
      
        /*合计*/
        //sumFee =  registerFee + realEstateStampTax + nFee;
        sumFee = registerFee + realEstateStampTax + nFee+tg_fee;

         /*输出首次置业测试日志，可在Filter中筛选结果。 */
        if(tax_first){
          appConsole.log("============计算买卖-首次置业费用如下===============");
          appConsole.log("输入的售价和登记价值为：" + txt_register, 0);
          appConsole.log("小于小于50万部分：" + f_fees_1, 0);
          appConsole.log("50-1000000万的部分：" + f_fees_2, 0);
          appConsole.log("1000000万-2000000万的部分：" + f_fees_3, 0);
          appConsole.log("2000000万-3000000万的部分：" + f_fees_4, 0);
          appConsole.log("3000000万-5000000万的部分：" + f_fees_5, 0);
          appConsole.log("超过5000000万的部分：" + f_fees_6, 0);
          appConsole.log("总公证手续费" + sumFee, 0);
          appConsole.log("印花税" + stampTax, 0);
          appConsole.log("印花税2" + stampTax2, 0);
          appConsole.log("另收款项" + otherFee, 0);
          appConsole.log("公证费总计：【" + nFee + "】", 0);   
          appConsole.log("不动产转移印花税：【" + realEstateStampTax + "】", 0); 
          appConsole.log("取得额外印花税：【" + tg_fee+"】",0);
          appConsole.log("登记费：【" + registerFee +"】",0); 
          
          
        }else{
          /*输出非首次置业测试日志 */
          appConsole.log("============计算买卖-非首次置业费用如下===============");
          appConsole.log("输入的售价和登记价值为：" + txt_register, 0);
          appConsole.log("小于小于50万部分：" + n_fees_1, 0);
          appConsole.log("50-1000000万的部分：" + n_fees_2, 0);
          appConsole.log("1000000万-2000000万的部分：" + n_fees_3, 0);
          appConsole.log("2000000万-5000000万的部分：" + n_fees_4, 0);
          appConsole.log("超过5000000万的部分：" + n_fees_5, 0);
          appConsole.log("总公证手续费" + sumFee, 0);
          appConsole.log("印花税" + stampTax, 0);
          appConsole.log("印花税2" + stampTax2, 0);
          appConsole.log("另收款项" + otherFee, 0);
          appConsole.log("公证费总计：【" + nFee + "】", 0);   
          appConsole.log("不动产转移印花税：【" + realEstateStampTax + "】", 0); 
          appConsole.log("取得额外印花税：【" + tg_fee + "】", 0);
          appConsole.log("登记费：【" + registerFee + "】", 0);  
        }

        return{
          tax_type:"tax-type-buy",
          txt_register: txt_register,
          realEstateStampTax:realEstateStampTax,
          registerFee: registerFee,
          nFee: nFee,
          sumFee: sumFee,
          isFirst: tax_first,
          isStamp: tax_extraTax,
          tg_fee: tg_fee
          

        }


      },

      /*计算买卖及按揭费用*/
      "tax-type-buyAndMortgage": function (mortgageObj, buyObj){

        /* 
        公式为：
       【公证费=(按揭公证费+买卖公证费)-200】
       【买卖不动产印花税=买卖不动产印花税】
       【登记费=按揭公证费+买卖公证费】
        */
        //appConsole.log(buyObj);
        console.log(mortgageObj.mortgageNFee + "+" + buyObj.nFee);
        var sumNFee = Math.ceil(mortgageObj.mortgageNFee + buyObj.nFee)-200
        var sumRegFee = Math.ceil((buyObj.registerFee + mortgageObj.mortgageRegFee));
        var sumTax = buyObj.realEstateStampTax;
        //var sumFee = sumNFee + sumRegFee + sumTax; 
        var sumFee = sumNFee + sumRegFee + sumTax + buyObj.tg_fee;
        /*输出计算买卖及按揭日志*/
        appConsole.log("=============计算买卖及按揭费用=============");
        appConsole.log("总买卖及按揭公证费",0);
        appConsole.log(sumNFee,0);
        appConsole.log("总不动产印花税",0);
        appConsole.log(sumTax,0);
        appConsole.log("总买卖及按揭登记费",0);
        appConsole.log(sumRegFee,0);
        appConsole.log("总值：",0);
        appConsole.log(sumFee,0);
        return{
          tax_type:"tax-type-buyAndMortgage",
          sumNFee: sumNFee,
          sumTax: sumTax,
          sumFee: sumFee,
          sumRegFee: sumRegFee,
          mortgageObj: mortgageObj,
          buyObj: buyObj
                    
        }
      },


      /*计算按揭费用*/
      "tax-type-mortgage": function (agParam,isMerge){
        /*
        公式为：
       【年利率金额=*(年利率+0.03)*3+贷款额/10+贷款额】
       【按揭登记费用= 年利率金额各项登记费+公证书费用+另收费用】
       【按揭公证费用= 贷款额各项公证费+登记费】
        */

        /*借贷金额*/
        var txt_loan =  new Number(agParam.txt_loan);

        /*年利率*/
        var txt_rate = new Number(agParam.txt_rate);
        
        var tax_loan_currency = agParam.tax_loan_currency;

        /*转换借贷利率*/
        if (tax_loan_currency=="HK"){
            txt_loan = txt_loan*1.03;
            appConsole.log("是否HK：" + txt_loan);
        }


        /*年利率金额*/
        var rate_fee = txt_loan * (txt_rate + 0.03) * 3 + txt_loan / 10 + txt_loan;
        appConsole.log(rate_fee);
        /*按揭公证费用*/
        var mortgageNFee=0;

        /*公证书费用 */
        var certificateFee=100;
        
        /*另收费用 */
        var otherFee=100;
        
        var mnf_fee_1, mnf_fee_2, mnf_fee_3, mnf_fee_4, mnf_fee_5;

        /*逐项获取公证费超出部分*/
        
        mnf_fee_1 = agTaxRangeContext.getFeeByMin(txt_loan,500000);
        
        mnf_fee_2 = agTaxRangeContext.getFeeByRange(txt_loan, [500000,1000000]);
        
        mnf_fee_3 = agTaxRangeContext.getFeeByRange(txt_loan, [1000000, 2000000]);
        
        mnf_fee_4 = agTaxRangeContext.getFeeByRange(txt_loan, [2000000, 5000000]);

       

        mnf_fee_5 = agTaxRangeContext.getFeeByMax(txt_loan,5000000);

        /*计算按揭公证费用 */
        if (isMerge){
          mortgageNFee = (mnf_fee_1 * 0.005) + (mnf_fee_2 * 0.004) + (mnf_fee_3 * 0.003)
            + (mnf_fee_4 * 0.002) + (mnf_fee_5 * 0.001)
            + certificateFee + otherFee;
        }
        else{
          mortgageNFee = Math.ceil((mnf_fee_1 * 0.005) + (mnf_fee_2 * 0.004) + (mnf_fee_3 * 0.003)
            + (mnf_fee_4 * 0.002) + (mnf_fee_5 * 0.001)
            + certificateFee + otherFee);
        }


        /*合计 */
        var sumFee=0;

        /*按揭登记费用*/
        var mortgageRegFee=0;

        /*登记费*/
        var regFee=100;

        var mtr_fee_1, mtr_fee_2, mtr_fee_3;

        /*逐项获取登记费超出部分 */

        mtr_fee_1 = agTaxRangeContext.getFeeByMin(rate_fee,500000);

        mtr_fee_2 = agTaxRangeContext.getFeeByRange(rate_fee, [500000, 1000000]);

        mtr_fee_3 = agTaxRangeContext.getFeeByMax(rate_fee, 1000000);
        
        /*计算按揭登记费用*/
        

        if (isMerge){
          mortgageRegFee = ((mtr_fee_1) * 0.004 + (mtr_fee_2) * 0.003 + (mtr_fee_3) * 0.002) + regFee;
        }

        else{
          mortgageRegFee = Math.ceil(((mtr_fee_1) * 0.004 + (mtr_fee_2) * 0.003 + (mtr_fee_3) * 0.002) + regFee);
        }

        /*计算合计*/
        sumFee = mortgageRegFee + mortgageNFee;
       
        /*输出计算按揭费用日志*/
        appConsole.log("===============计算按揭费用==============");
        appConsole.log("借贷金额：" + txt_loan,0);
        appConsole.log("年利率" + txt_rate, 0);
        appConsole.log("年利率金额费用:【" + rate_fee+"】", 0);
        appConsole.log("按揭”公证“费用:【" + mortgageNFee + "】", 0);
        appConsole.log("按揭”登记“费用:【" + mortgageRegFee + "】", 0);
        


        return {
          tax_type: "tax-type-mortgage",
          txt_loan: txt_loan,
          txt_rate: txt_rate,
          mortgageNFee: mortgageNFee,
          mortgageRegFee: mortgageRegFee,
          rate_fee: rate_fee,
          sumFee:sumFee     
        }
      },

      /*计算临时登记费用*/
      "tax-type-register": function (agParam){

        /*
          公式为:
         【临时登记=登记费用+各项楼价超出的登记费。】
         */

        /*楼价*/
        var txt_floor =Math.ceil(new Number(agParam.txt_floor));

        var tax_floor_currency = agParam.tax_floor_currency;

        /*临时登记费用*/
        var tmpRegisterFee = 0;

        /*登记费用*/
        var tmpRegFee=100;

        /*汇率*/
        if (tax_floor_currency=="HK"){
          txt_floor = txt_floor*1.03;
        }
        
        var r_fee_1,r_fee_2,r_fee_3;


        
        /*小于500000万部分 */
        r_fee_1=agTaxRangeContext.getFeeByMin(txt_floor,500000);
        r_fee_2 = agTaxRangeContext.getFeeByRange(txt_floor, [500000, 1000000]);
        r_fee_3 = agTaxRangeContext.getFeeByMax(txt_floor,1000000);

        /*计算临时登记费用 */
        tmpRegisterFee = Math.ceil(tmpRegFee + (r_fee_1 * 0.004) + (r_fee_2 * 0.003) + (r_fee_3 * 0.002));


        /*输出计算临时登记费日志*/
        appConsole.log("============临时登记费===============", 0);
        appConsole.log("楼价:" + txt_floor, 0);
        appConsole.log("临时登记费【" + tmpRegisterFee+"】",0);

        return {
          tax_type: "tax-type-register",
          tmpRegisterFee: tmpRegisterFee,
          txt_floor: txt_floor
        }

      }
  } 



  var testAgContent = {
    test_tax_type_buy: function () {
      agContext["tax-type-buy"](
        {
          tax_extraTax:true,
          tax_first: false,
          txt_register: 10000
        }

      );
    },

    test_tax_type_register:function(){
      agContext["tax-type-register"](
        {
          txt_floor: 1000
        });
    },
    test_tax_type_mortgage:function(){
      agContext["tax-type-mortgage"](
        {
          txt_loan:1000,
          txt_rate:0.5
        }
      );
    }, 
    test_tax_type_buyAndMortgage: function(){
      agContext["tax-type-buyAndMortgage"](
        agContext["tax-type-mortgage"](
          {
            txt_loan: 10000,
            txt_rate: 0.01
          }
        ),
        agContext["tax-type-buy"](
          {
            tax_extraTax:true,
            tax_first: false,
            txt_register: 10000
          }

        ),

      );   
    }

  }


  //testAgContent.test_tax_type_buy();
  //testAgContent.test_tax_type_register();
  //testAgContent.test_tax_type_mortgage();
  testAgContent.test_tax_type_buyAndMortgage();
  



  /*计税主对象*/
  var tax = function (agContext,displayContext,verifyContext){
    /*计算参数*/

    this.agContext = agContext;
    this.displayContext = displayContext;
    this.verifyContext = verifyContext;
    this.taxTools = taxTools;

    /*汇率对象*/
    this.rate={
      HK:0,
      MA:0
    };
    this.wx={};
    this.page={};


  }
  /*设置计税参数*/
  tax.prototype.setParam=function(id,value,types){

    switch (types) {
      case "bool":
        value = this.taxTools.toBoolean(value);
        break;

      case "fee":
        value = value.replace(/\,/g,"");
        break;

      case "percentage":
        value = this.taxTools.toPercentage(value);
        //toPercentage toThousands
        break;
      case "text":
        value=value;
        break;
    }
    console.log("param:",value);
    this.page.setData({
      ["agParam."+id]:value
    })
  };

  /*设置对应显示块*/
  tax.prototype.setDisplay=function(target){
    console.log(target);
    var displayObj = this.page.data.displayObj;
    for (var key in displayObj){
      displayObj[key]=false;
    }

    displayContext[target].call(this, displayObj,this.page.data);
    this.page.setData({
      displayObj: displayObj
    });
  },

  /*根据类型,以及对应的参数，得出税务结果 */
  tax.prototype.getResult=function(){
    var agParam=this.page.data.agParam;
    console.log(agParam);
    if (agParam.tax_type =="tax-type-buyAndMortgage"){
      //
      return agContext[agParam.tax_type](
        agContext["tax-type-mortgage"](agParam,true),
        agContext["tax-type-buy"](agParam,true)
       );
    }
    else{
      return agContext[agParam.tax_type](agParam);
    }
    
  },

  /*初始化*/
  tax.prototype._init=function(page){
    this.page=page;
    page.setData({
      agParam: {
        txt_register: 0,
        tax_register_currency: "HK",
        txt_floor: 0,
        tax_floor_currency: "HK",
        txt_loan: 0,
        tax_loan_currency: "HK",
        txt_rate: 0,
        tax_first: false,
        tax_extraTax: false,
        tax_type:"tax-type-buy",
        tax_gtax:"gtax_2",
        tax_isGtax:false
        
      },
      displayObj: {
        txt_register_display: true,
        txt_loan_display: true,
        tax_rate_display: true,
        tax_first_display: true,
        tax_extraTax_display: true,
        txt_floor_display: true,
        tax_gtax_display:true,
        tax_isGtax:true
      }
    });
  }
  

  return new tax();

})(this);

module.exports.tax = tax;
